<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : AudioOutput</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">
  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName">AudioOutput</p>
    	
       <p class="linkListHeader">Fields</p>
       <p class="linkList">
           
    <a href="audiooutput_field_left.html" title="The AudioBuffer containing the left channel samples. If this is a mono
 sound, it contains the single channel of audio.">left</a><br/>
    
    <a href="audiooutput_field_mix.html" title="The AudioBuffer containing the mix of the left and right channels. If this is
 a mono sound, <code>mix</code> contains the same
 samples as <code>left</code>.">mix</a><br/>
    
    <a href="audiooutput_field_right.html" title="The AudioBuffer containing the right channel samples. If this is a mono
 sound, <code>right</code> contains the same samples as
 <code>left</code>.">right</a><br/>
    
	   </p>
   
    	
       <p class="linkListHeader">Methods</p>
       <p class="linkList">
           
    <a href="audiooutput_method_addlistener.html" title="Add an AudioListener to this sound generating object.">addListener ( )</a><br/>
    
    <a href="audiooutput_method_buffersize.html" title="The internal buffer size of this sound object.">bufferSize ( )</a><br/>
    
    <a href="audiooutput_method_getbalance.html" title="Returns the current balance.">getBalance ( )</a><br/>
    
    <a href="audiooutput_method_getdurationfactor.html" title="Return the current value of the duration factor for this output.">getDurationFactor ( )</a><br/>
    
    <a href="audiooutput_method_getformat.html" title="Returns AudioFormat object that describes the audio properties 
 of this sound generating object.">getFormat ( )</a><br/>
    
    <a href="audiooutput_method_getgain.html" title="Returns the current gain.">getGain ( )</a><br/>
    
    <a href="audiooutput_method_getnoteoffset.html" title="Return the current value of the note offset for this output.">getNoteOffset ( )</a><br/>
    
    <a href="audiooutput_method_getpan.html" title="Returns the current pan.">getPan ( )</a><br/>
    
    <a href="audiooutput_method_gettempo.html" title="Return the current tempo of the AudioOuput. 
 Tempo is expressed in BPM (beats per minute).">getTempo ( )</a><br/>
    
    <a href="audiooutput_method_getvolume.html" title="Returns the current volume.">getVolume ( )</a><br/>
    
    <a href="audiooutput_method_ismuted.html" title="Returns true if the sound is muted.">isMuted ( )</a><br/>
    
    <a href="audiooutput_method_mute.html" title="Mutes the sound.">mute ( )</a><br/>
    
    <a href="audiooutput_method_pausenotes.html" title="pause note processing">pauseNotes ( )</a><br/>
    
    <a href="audiooutput_method_playnote.html" title="Schedule a "note" to played by the output.">playNote ( )</a><br/>
    
    <a href="audiooutput_method_removelistener.html" title="Removes an AudioListener that was previously 
 added to this sound object.">removeListener ( )</a><br/>
    
    <a href="audiooutput_method_resumenotes.html" title="Resume note processing.">resumeNotes ( )</a><br/>
    
    <a href="audiooutput_method_samplerate.html" title="Returns the sample rate of this sound object.">sampleRate ( )</a><br/>
    
    <a href="audiooutput_method_setbalance.html" title="Sets the balance.">setBalance ( )</a><br/>
    
    <a href="audiooutput_method_setdurationfactor.html" title="Sets a factor that will scale durations passed to subsequent playNote calls.">setDurationFactor ( )</a><br/>
    
    <a href="audiooutput_method_setgain.html" title="Sets the gain.">setGain ( )</a><br/>
    
    <a href="audiooutput_method_setnoteoffset.html" title="Sets the amount of time added to all start times passed to playNote calls.">setNoteOffset ( )</a><br/>
    
    <a href="audiooutput_method_setpan.html" title="Sets the pan.">setPan ( )</a><br/>
    
    <a href="audiooutput_method_settempo.html" title="Set the tempo of the AudioOutput to change the meaning of start times and durations for notes.">setTempo ( )</a><br/>
    
    <a href="audiooutput_method_setvolume.html" title="Sets the volume.">setVolume ( )</a><br/>
    
    <a href="audiooutput_method_shiftbalance.html" title="Transitions the balance from one value to another.">shiftBalance ( )</a><br/>
    
    <a href="audiooutput_method_shiftgain.html" title="Transitions the gain from one value to another.">shiftGain ( )</a><br/>
    
    <a href="audiooutput_method_shiftpan.html" title="Transitions the pan from one value to another.">shiftPan ( )</a><br/>
    
    <a href="audiooutput_method_shiftvolume.html" title="Transitions the volume from one value to another.">shiftVolume ( )</a><br/>
    
    <a href="audiooutput_method_type.html" title="The type is an int describing the number of channels
 this sound object has.">type ( )</a><br/>
    
    <a href="audiooutput_method_unmute.html" title="Unmutes the sound.">unmute ( )</a><br/>
    
	   </p>
   
    </td>
    <td class="mainText border-left">
    	<p>
 An AudioOutput is a connection to the output of a computer's sound card. 
 Typically the computer speakers are connected to this. 
 You can use an AudioOutput to do real-time sound synthesis by patching 
 UGens to an output object. You can get an AudioOutput object from Minim 
 using one of five methods:
 </p>
 <pre>
 AudioOutput getLineOut()
 
 // specifiy either Minim.MONO or Minim.STEREO for type
 AudioOutput getLineOut(int type)
 
 // bufferSize is the size of the left, right,
 // and mix buffers of the output you get back
 AudioOutput getLineOut(int type, int bufferSize)
 
 // sampleRate is a request for an output of a certain sample rate
 AudioOutput getLineOut(int type, int bufferSize, float sampleRate)
 
 // bitDepth is a request for an output with a certain bit depth
 AudioInput getLineOut(int type, int bufferSize, float sampleRate, int bitDepth)
 </pre>
 <p>
 In the event that an output doesn't exist with the requested parameters, 
 Minim will spit out an error and return null. 
 In general, you will want to use one of the first two methods listed above.
 </p>
 <p>
 In addition to directly patching UGens to the output, you can also schedule 
 "notes" to be played by the output at some time in the future. This can 
 be very powerful when writing algorithmic music and sound. See the playNote
 method for more information.
 </p>
    	<p class="memberSectionHeader">Constructors</p>
    	<pre></pre>
    	
    	<p class="memberSectionHeader">Related</p>
    	<A href="minim_class_minim.html">Minim</A><BR>
<A href="ugen_class_ugen.html">UGen</A><BR>
<A href="audiooutput_method_playnote.html">playNote ( )</A><BR>

    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  * This sketch demonstrates how to create synthesized sound with Minim 
  * using an AudioOutput and an Oscil. An Oscil is a UGen object, 
  * one of many different types included with Minim. By using 
  * the numbers 1 thru 5, you can change the waveform being used
  * by the Oscil to make sound. These basic waveforms are the 
  * basis of much audio synthesis. 
  * 
  * For many more examples of UGens included with Minim, 
  * have a look in the Synthesis folder of the Minim examples.
  * &lt;p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/
  */

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim       minim;
AudioOutput out;
Oscil       wave;

void setup()
{
  size(512, 200, P3D);
  
  minim = new Minim(this);
  
  // use the getLineOut method of the Minim object to get an AudioOutput object
  out = minim.getLineOut();
  
  // create a sine wave Oscil, set to 440 Hz, at 0.5 amplitude
  wave = new Oscil( 440, 0.5f, Waves.SINE );
  // patch the Oscil to the output
  wave.patch( out );
}

void draw()
{
  background(0);
  stroke(255);
  strokeWeight(1);
  
  // draw the waveform of the output
  for(int i = 0; i &lt; out.bufferSize() - 1; i++)
  {
    line( i, 50  - out.left.get(i)*50,  i+1, 50  - out.left.get(i+1)*50 );
    line( i, 150 - out.right.get(i)*50, i+1, 150 - out.right.get(i+1)*50 );
  }

  // draw the waveform we are using in the oscillator
  stroke( 128, 0, 0 );
  strokeWeight(4);
  for( int i = 0; i &lt; width-1; ++i )
  {
    point( i, height/2 - (height*0.49) * wave.getWaveform().value( (float)i / width ) );
  }
}

void mouseMoved()
{
  // usually when setting the amplitude and frequency of an Oscil
  // you will want to patch something to the amplitude and frequency inputs
  // but this is a quick and easy way to turn the screen into
  // an x-y control for them.
  
  float amp = map( mouseY, 0, height, 1, 0 );
  wave.setAmplitude( amp );
  
  float freq = map( mouseX, 0, width, 110, 880 );
  wave.setFrequency( freq );
}

void keyPressed()
{ 
  switch( key )
  {
    case '1': 
      wave.setWaveform( Waves.SINE );
      break;
     
    case '2':
      wave.setWaveform( Waves.TRIANGLE );
      break;
     
    case '3':
      wave.setWaveform( Waves.SAW );
      break;
    
    case '4':
      wave.setWaveform( Waves.SQUARE );
      break;
      
    case '5':
      wave.setWaveform( Waves.QUARTERPULSE );
      break;
     
    default: break; 
  }
}
</pre>
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>